// index page
// ============

define(
    [ 'require', 'zepto', 'wx', 'ejs', 'utils', 'sui' ],
    function(require, $, wx, ejs, utils) {
      return {
        init : function(data) {
          this.initPage()
          this.unionid = data.unionid  // "o4UI81Pq-DgJTK_mawcG2IGnWIkk"
          utils.configWeixin(data.jsConfig, true, {
            name: "赌你会瘦",
            desc: "您的小伙伴邀请您参加人马君赌你会瘦活动，快来一起瓜分万元奖金吧~",
            link: window.__CTX__.domain + "/mall",
            cover : data.avatar
          });
        },
        initPage : function() {
          var that = this;
          var html = '<%= betTime %>';
          var bonusHtml = '<div class=" text-center number">'
                + '<img src="'
                + window.__CTX__.resource
                + '<%= bonusData.avatar %>" style="display: inline-block;height: 1.2rem; vertical-align: middle;"/>'
                + '<span class="item">5</span><span class="item">8</span>人参与'
                + '</div>'
                + '<div class="text-center">'
	            + '<div class="price clearfix">'
	            + '<span class="item">￥</span>'
	            + '<% for(var i=0; i< bonusData.price.length; i++){ %>'
	            + '<% if () { %>
	            + '<span class="pull-left">.</span>'
	            + '<% } %>'
	            + '<% else { %>
	            + '<span class="item"><%= bonusData.price[i] %></span>'
	            + '<% } %>'
	            + '</div>'
	            + '</div>';
        	  
          var result = ejs.render(html, {
              betTime : '2018.12.28',
            })
          var bonusResult = ejs.render(bonusHtml, {
              bonusData: {
                'avatar': '/images/bonus.png',
                'price': '8950.00'
              }
          });
            
        
          $('.activity-header .time').html(result);
          $('.activity-bonus').html(bonusResult)
        }
      }
    })